package org.liang.base.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Configuration;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Configuration //配置类
public class AjaxResult {
    private Boolean success;
    private String msg;
    private Object data;

    public static AjaxResult success(){
        AjaxResult result = new AjaxResult();
        result.setSuccess(true);
        result.setMsg("操作成功");
        return result;
    }

    public static AjaxResult success(Object data){
        AjaxResult result = new AjaxResult();
        result.setSuccess(true);
        result.setMsg("操作成功");
        result.setData(data);
        return result;
    }

    public static AjaxResult success(String msg,Object data){
        AjaxResult result = new AjaxResult();
        result.setSuccess(true);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static AjaxResult error(){
        AjaxResult result = new AjaxResult();
        result.setSuccess(false);
        result.setMsg("操作失败");
        return result;
    }

    public static AjaxResult error(String msg){
        AjaxResult result = new AjaxResult();
        result.setSuccess(false);
        result.setMsg("操作失败"+msg);
        return result;
    }

}
